from celery_tasks.main import app
from ronglian_sms_sdk import SmsSDK

@app.task
def celery_send_smscode(mobile,sms_code):
    """定义任务函数"""
    accId = '8aaf0708762cb1cf0176c609243535de'
    accToken = 'f03d0d5985ee400caf29c2971a75cd9a'
    appId = '8aaf0708762cb1cf0176c60924fd35e5'
    sdk = SmsSDK(accId, accToken, appId)
    """
    tid:选用模板1
    mobile：接收短信验证码的手机号
    datas: 要发送的验证码及有效时间
    """
    tid = '1'
    mobile = '%s' % mobile
    datas = (sms_code, 5)
    sdk.sendMessage(tid, mobile, datas)
